<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="time">
        2024-9-14
    </div>
    <ul>
        <li>知否知否，应是绿肥红瘦</li>
        <li>知否知否，应是绿肥红瘦</li>
        <li>知否知否，应是绿肥红瘦</li>
        <li>知否知否，应是绿肥红瘦</li>
        <li>知否知否，应是绿肥红瘦</li>
    </ul>
    <div class="box">盒子</div>
    <div class="box">盒子</div>
    <script>
        var timer = document.getElementById('time');
        timer.innerHTML = '时间';
        var lis = document.getElementsByTagName('li');
        console.log(lis);
        var boxs = document.getElementsByClassName('box');
        console.log(boxs);
        //querySelector 返回指定选择器的第一个元素对象 切记 里面的选择器需要加符号 .box #time
        var box = document.querySelector('.box');
        console.log(box);
        //获取body元素
        var bodyEmt = document.body;
        console.log(bodyEmt);
        //获取html元素
        var htmlEmt = document.documentElement;
        console.log(htmlEmt);
        var div = document.querySelector('div');
        div.onclick = function() {
            console.log('我被点击了');
            alert('666');

        }
    </script>
</body>

</html>